<include file="public/layout"/>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>矿机设置</h3>
                <h5>矿机基本设置</h5>
            </div>
            <ul class="tab-base nc-row">
                <foreach name="group_list" item="v" key="k">
                    <li><a href="{:U('World.World/system',['inc_type'=> $k])}" <if condition="$k==$inc_type">class="current"</if>><span>{$v}</span></a></li>
                </foreach>
            </ul>
        </div>
    </div>
    <!-- 操作说明 -->
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示"></span></div>
        <ul>
            <li>切不可频繁更改</li>
        </ul>
    </div>
    <form method="post" enctype="multipart/form-data" id="handlepost" name="form1" action="{:U('World.World/handle')}">
        <input type="hidden" name="inc_type" value="{$inc_type}">
        <div class="ncap-form-default">

            <div class="bDiv"  style="height: auto;">
                <dl class="row">
                    <dt class="tit">是否开启推荐奖</dt>
                    <dd class="opt">
                        <div class="onoff">
                            <label for="switch1" class="cb-enable  <if condition="$config['switch'] eq 1">selected</if>">开启</label>
                            <label for="switch0" class="cb-disable <if condition="$config['switch'] eq 0">selected</if>">关闭</label>
                            <input type="radio"  id="switch1" onclick="ajax_switch(1)" name="switch" value="1" <if condition="$config['switch'] eq 1">checked="checked"</if>>
                            <input type="radio"  id="switch0" onclick="ajax_switch(0)" name="switch" value="0" <if condition="$config['switch'] eq 0">checked="checked"</if> >
                        </div>
                        <p class="notic">注意：开关，切勿频繁修改分佣参数，容易引起系统运算报错</p>
                    </dd>
                </dl>
                <div class="ncap-form-default" id="switch_on_off" <if condition="$config['switch'] eq 0">style="display: block;"</if>>
                    <dl class="row">
                        <dt class="tit">
                        </dt>
                        <dd class="opt">
                            <notempty name="$config">
                                <foreach name="$config['prize']" item="v"  key="k">
                                    <div class="add_recommend_level">
                                        <span>直推</span>
                                        <input type="text" class="form-control oud" value="{$v['first_leader']}" name="first_leader[]">
                                        <span class="zs">人，无限层&nbsp;</span>
                                        <input type="text" class="form-control oud" value="{$v['team']}" name="team[]">
                                        
                                        <span>赠送&nbsp;</span>
                                        <select class="form-control oudy" onchange="change_a(this)" name="miner[]">
                                            <option value="0">请选择1</option>
                                            <foreach name="miner_list" item="vo">
                                                <option value="{$vo['miner_id']}" fs="{$v['miner']}" <if condition="$vo['miner_id'] eq $v['miner']">selected="selected"</if> >{$vo['miner_name']}</option>
                                            </foreach>
                                        </select>
                                        <input type="text" class="form-control oud" value="{$v['number']}" name="number[]">台
                                        <span></span>
                                        <if condition="$k eq 0">
                                            <span><a onclick="add_recommend_level(this);">添加</a></span>
                                        <else />
                                            <span><a onclick="del_recommend_level(this);">删除</a></span>
                                        </if>
                                    </div>
                                </foreach>
                            <else />
                                <div class="add_recommend_level">
                                    <span>直推</span>
                                    <input type="text" class="form-control oud" value="" name="first_leader[]">
                                    <span class="zs">人，无限层&nbsp;</span>
                                    <input type="text" class="form-control oud" value="" name="team[]">
                                    <span>赠送&nbsp;</span>
                                    <select class="form-control oudy" onchange="change_a(this)" name="miner[]">
                                        <option value="0">请选择</option>
                                        <foreach name="miner_list" item="vo">
                                            <option value="{$vo['miner_id']}">{$vo['miner_name']}</option>
                                        </foreach>
                                    </select>
                                    <input type="text" class="form-control oud" value="" name="number[]">台
                                    <span></span>
                                    <span><a onclick="add_recommend_level(this);">添加</a></span>
                                </div>
                            </notempty>
                        </dd>
                    </dl>

                    <div class="bot"><a href="JavaScript:void(0);" onclick="adsubmit()" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
                </div>
            </div>
        </div>

        </div>
    </form>
</div>
<script type="text/javascript">

</script>
<div id="goTop">
    <a href="JavaScript:void(0);" id="btntop">
        <i class="fa fa-angle-up"></i>
    </a>
    <a href="JavaScript:void(0);" id="btnbottom">
        <i class="fa fa-angle-down"></i>
    </a>
</div>
</body>
<script>
    function ajax_subimit(da){
        $.ajax({
            type: "POST",
            url: "/index.php/Admin/World.World/handle",
            data: da,
            success: function(res){
                layer.msg('保存成功！', {icon: 1});
            }
        })
    }
    function adsubmit(action){
        //异步提交
        var da = $('#handlepost').serialize();
        ajax_subimit(da)

    }

function ajax_switch(num){
    if (num == 1) {
        // $('#switch_on_off').show();
    } else {
        // $('#switch_on_off').hide();
        $('input[name="switch"]:checked').val(0);
        var da = $('#handlepost').serialize();
        ajax_subimit(da)
    }
}
var bool = $('input[name="switch"]:checked').val();
if (bool == 1) {
    // $('#switch_on_off').show()
}

//添加推荐层条件
function add_recommend_level(that){
    var html ='<div class="add_recommend_level"><span>直推&nbsp;</span><input type="text" class="form-control oud" value="" name="first_leader[]">';
        html +='<span class="zs">&nbsp;人，无限层&nbsp;&nbsp;</span><input type="text" class="form-control oud" value="" name="team[]"><span>&nbsp;赠送&nbsp;&nbsp;</span>';
        html +='<select class="form-control oudy" onchange="change_a(this)" name="miner[]"><option value="0">请选择</option>';
        html +='<foreach name="miner_list" item="vo"><option value="{$vo[miner_id]}">{$vo[miner_name]}</option></foreach></select>';
        html +='&nbsp;<input type="text" class="form-control oud" value="" name="number[]">台<span></span>';


    // var html = '<div class="add_recommend_level"><span>推荐身份设置&nbsp;&nbsp;</span><select class="form-control oudy" name="miner[]"><option value="0">请选择</option><foreach name="user_level" item="vo"><option value="{$vo[level_id]}">{$vo[level_name]}</option></foreach></select> <span>元,直推&nbsp;</span><input type="text" class="form-control oud" value="0" name="first_leader[]"><span class="zs">&nbsp;，二级&nbsp;&nbsp;</span><span></span><input type="text" class="form-control oud" value="0" name="team[]"><span class="zs">&nbsp;元</span>&nbsp;&nbsp;&nbsp;<span><a onclick="del_recommend_level(this);">删除</a></span></div>'
    $(that).parent().parent().parent().append(html);
}
//删除推荐层条件
function del_recommend_level(that){
    $(that).parent().parent().remove();
}
</script>
</html>